#include "pcb.h"

PCB::PCB(QString pid, int priority, int runTime, int memoryNeed)
{
    this->pid = pid;
    this->runTime = runTime;
    this->priority = priority;
    status = BACKUP;
    next = nullptr;
    this->memoryNeed = memoryNeed;
}

PCB::PCB(PCB * p)
{
    this->pid = p->getPID();
    this->runTime = p->getRuntime();
    this->priority = p->getPriority();
    this->status = p->getStatus();
    this->memoryNeed = p->getMemoryNeed();
    this->memoryBegin = p->getMemoryBegin();
    next = nullptr;
}

void PCB::setPID(QString value){
    pid = value;
}

void PCB::setNext(PCB * value){
    next = value;
}

void PCB::setStatus(STATUS value){
    status = value;
}

void PCB::setRuntime(int value){
    runTime = value;
}

void PCB::setMemoryNeed(int value){
    memoryNeed = value;
}

void PCB::setMemoryBegin(int value){
    memoryBegin = value;
}

void PCB::setColorOrder(int value){
    colorOrder = value;
}

void PCB::delRuntime(int value){
    runTime -= value;
}

void PCB::delPriority(int value){
    priority -= value;
}

QString PCB::getPID(){
    return pid;
}

STATUS PCB::getStatus(){
    return status;
}

int PCB::getRuntime(){
    return runTime;
}

int PCB::getPriority(){
    return priority;
}

int PCB::getMemoryNeed(){
    return memoryNeed;
}

int PCB::getMemoryBegin() const{
    return memoryBegin;
}

int PCB::getColorOrder(){
    return colorOrder;
}

void PCB::refreshColor()
{
    colorOrder = 1;
}
